import axios from 'axios'

import { accessToken, userKey } from '../config/index'

// 创建 axios 实例
const request = axios.create({
  // API 请求的默认前缀
  timeout: 6000 // 请求超时时间
})

// request interceptor
request.interceptors.request.use(cfg => {
  cfg.headers['Random-Str'] = accessToken.randomstr || 'aa91295e83ac71ba5b27aa081fe0f435'
  cfg.headers['User-Key'] = userKey || 'bpm_web_user'
  cfg.headers['Access-Token'] = accessToken.accesstoken || 'be61cf06dec5bbb283bbbe7a698b18e7'
  cfg.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
  return cfg
})

export default request
